#pragma once
#include<iostream>
#include<string>
#include<pthread.h>
#include"Mutex.hpp"

namespace MyCond
{
    using namespace MyMutex;

    class Cond
    {
    public:
        Cond()
        {
            int n = pthread_cond_init(&_cond,nullptr);
            (void)n;
        }
        void Wait(Mutex &mutex)
        {
            int n = pthread_cond_wait(&_cond,mutex.GetOriginal());
            (void)n;
        }
        void Notify()
        {
            int n = pthread_cond_signal(&_cond);
            (void)n;
        }
        void NotiAll()
        {
            int n = pthread_cond_broadcast(&_cond);
            (void)n;
        }
        ~Cond()
        {
            int n = pthread_cond_destroy(&_cond);
            (void)n;
        }

    private:
        pthread_cond_t _cond;
    };

}
